/*
 Navicat MySQL Data Transfer

 Source Server         : 192.168.5.46
 Source Server Type    : MySQL
 Source Server Version : 50718
 Source Host           : 192.168.5.46:3306
 Source Schema         : auto_code

 Target Server Type    : MySQL
 Target Server Version : 50718
 File Encoding         : 65001

 Date: 16/05/2019 13:16:57
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for back_user
-- ----------------------------
DROP TABLE IF EXISTS `back_user`;
CREATE TABLE `back_user` (
  `username` varchar(20) NOT NULL COMMENT '用户名',
  `password` varchar(50) NOT NULL COMMENT '密码',
  `add_time` datetime NOT NULL COMMENT '添加时间',
  PRIMARY KEY (`username`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of back_user
-- ----------------------------
BEGIN;
INSERT INTO `back_user` VALUES ('aaaa', '123456', '2015-01-05 11:52:26');
INSERT INTO `back_user` VALUES ('admin', 'admin', '2014-06-24 10:12:49');
COMMIT;

-- ----------------------------
-- Table structure for datasource_config
-- ----------------------------
DROP TABLE IF EXISTS `datasource_config`;
CREATE TABLE `datasource_config` (
  `dc_id` int(11) NOT NULL AUTO_INCREMENT,
  `driver_class` varchar(50) DEFAULT NULL COMMENT '数据库驱动',
  `db_name` varchar(50) DEFAULT NULL,
  `ip` varchar(50) DEFAULT NULL,
  `port` int(11) DEFAULT NULL,
  `username` varchar(50) DEFAULT NULL,
  `password` varchar(50) DEFAULT NULL,
  `back_user` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`dc_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of datasource_config
-- ----------------------------
BEGIN;
INSERT INTO `datasource_config` VALUES (4, 'com.mysql.jdbc.Driver', 'auto_code', '192.168.5.46', 3306, 'devOps', '123456', 'admin');
INSERT INTO `datasource_config` VALUES (6, 'com.mysql.jdbc.Driver', 'localhost', 'localhost', 3306, 'root', '111111', 'admin');
COMMIT;

-- ----------------------------
-- Table structure for template_config
-- ----------------------------
DROP TABLE IF EXISTS `template_config`;
CREATE TABLE `template_config` (
  `tc_id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `save_path` varchar(100) DEFAULT NULL,
  `suffix` varchar(20) DEFAULT NULL,
  `file_name` varchar(50) DEFAULT NULL,
  `content` text,
  `back_user` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`tc_id`) USING BTREE,
  KEY `f_backuser` (`back_user`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8 COMMENT='模板表';

-- ----------------------------
-- Records of template_config
-- ----------------------------
BEGIN;
INSERT INTO `template_config` VALUES (44, 'v2_02_manager', 'manager', NULL, '${context.javaBeanName}Manager.java', 'package ${context.packageName}.manager;\n\nimport ${context.packageName}.domain.${context.javaBeanName};\nimport ${context.packageName}.domain.${context.javaBeanName}Query;\nimport infra.framework.common.manager.BaseManager;\n\npublic interface ${context.javaBeanName}Manager extends BaseManager<${context.javaBeanName}, ${context.javaBeanName}Query> {\n\n}', 'admin');
INSERT INTO `template_config` VALUES (45, 'v2_05_service', 'service', NULL, '${context.javaBeanName}Service.java', 'package ${context.packageName}.service;\n\nimport infra.framework.common.service.BaseService;\nimport ${context.packageName}.domain.${context.javaBeanName};\nimport ${context.packageName}.domain.${context.javaBeanName}Query;\n\npublic interface ${context.javaBeanName}Service extends BaseService<${context.javaBeanName}, ${context.javaBeanName}Query> {\n\n}', 'admin');
INSERT INTO `template_config` VALUES (47, 'v2_09_dao', 'dao', NULL, '${context.javaBeanName}Dao.java', 'package ${context.packageName}.dao;\n\nimport infra.framework.common.dao.BaseDao;\nimport ${context.packageName}.domain.${context.javaBeanName};\nimport ${context.packageName}.domain.${context.javaBeanName}Query;\n\npublic interface ${context.javaBeanName}Dao extends BaseDao<${context.javaBeanName}, ${context.javaBeanName}Query> {\n}', 'admin');
INSERT INTO `template_config` VALUES (48, 'v2_10_mapper', 'dao/mapper', NULL, '${context.javaBeanNameLF}Mapper.xml', '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE  mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\" >\n<mapper namespace=\"${context.packageName}.dao.${context.javaBeanName}Dao\">\n    <resultMap id=\"queryResultMap\" type=\"${context.packageName}.domain.${context.javaBeanName}\">\n        #foreach($column in $columns)\n        <result column=\"${column.columnName}\" property=\"${column.javaFieldName}\" jdbcType=\"${column.mybatisJdbcType}\" />\n        #end\n    </resultMap>\n    \n	<sql id=\"Base_Column_List\" >\n        #foreach($column in $columns)             \n         #if(${velocityCount} > 1),#end ${column.columnName} \n        #end\n    </sql>\n    \n    <sql id=\"query_condition\" >\n    	#foreach($column in $columns) \n            #if(!${column.isPk}) \n            <if test=\"query.${column.javaFieldName} !=null\">\n                and ${column.columnName}=#{query.${column.javaFieldName},jdbcType=${column.mybatisJdbcType}}\n            </if>\n            #end\n        #end\n    </sql>\n    \n    <delete id=\"delByCondition\">\n        DELETE\n        FROM ${table.tableName} t\n        <where>\n        	<include refid=\"query_condition\" />\n        </where>\n    </delete>\n    \n    <select id=\"findByCondition\" \n        resultMap=\"queryResultMap\">\n        SELECT <include refid=\"Base_Column_List\" />\n        FROM ${table.tableName} t\n        <where>\n        	<include refid=\"query_condition\" />\n        </where>\n        <choose>\n            <when test=\"query.sortName == null\">\n                ORDER BY t.${context.pkName} desc\n            </when>\n            <otherwise>\n                ORDER BY ${query.sortName}\n            </otherwise>\n        </choose>\n    </select>\n\n    <select id=\"findTotalCount\" \n        resultType=\"java.lang.Integer\">\n        SELECT count(1) FROM ${table.tableName} t\n        <where>\n        	<include refid=\"query_condition\" />\n        </where>\n    </select>\n\n    <insert id=\"save\" \n#if(${pkColumn.isIdentity})\n    keyProperty=\"entity.${context.javaPkName}\" keyColumn=\"${context.pkName}\" useGeneratedKeys=\"true\"\n#end\n    >\n    INSERT INTO ${table.tableName}\n         (\n #set ($i=0) \n        #foreach($column in $columns) \n            #if(!${column.isIdentityPk} and ${column.columnName} != \"create_time\" and ${column.columnName} != \"update_time\")               \n        #if($i > 0),#end ${column.columnName}\n#set($i=$i +1)\n            #end          \n        #end\n          )\n    VALUES (\n #set ($i=0) \n        #foreach($column in $columns) \n            #if(!${column.isIdentityPk} and ${column.columnName} != \"create_time\" and ${column.columnName} != \"update_time\")           \n        #if($i > 0),#end #{entity.${column.javaFieldName},jdbcType=${column.mybatisJdbcType}}\n#set($i=$i +1)\n            #end          \n        #end\n \n        )\n    </insert>\n\n    <insert id=\"saveSelective\" \n#if(${pkColumn.isIdentity})\n    keyProperty=\"entity.${context.javaPkName}\" keyColumn=\"${context.pkName}\" useGeneratedKeys=\"true\"\n#end\n    >\n    INSERT INTO ${table.tableName}\n         <trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\" >\n        #foreach($column in $columns) \n            #if(!${column.isIdentityPk} and ${column.columnName} != \"create_time\" and ${column.columnName} != \"update_time\")               \n            <if test=\"entity.${column.javaFieldName} != null\" >\n              ${column.columnName},\n              </if>\n            #end          \n        #end\n        </trim>\n    VALUES \n         <trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\" >\n        #foreach($column in $columns) \n            #if(!${column.isIdentityPk} and ${column.columnName} != \"create_time\" and ${column.columnName} != \"update_time\")           \n            <if test=\"entity.${column.javaFieldName} != null\" >\n              #{entity.${column.javaFieldName},jdbcType=${column.mybatisJdbcType}},\n            </if>\n            #end          \n        #end\n        </trim>\n    </insert>\n\n    <update id=\"update\" >\n    UPDATE ${table.tableName}\n    SET \n#set ($i=0) \n        #foreach($column in $columns) \n            #if(!${column.isPk} and ${column.columnName} != \"create_time\" and ${column.columnName} != \"update_time\")               \n        #if($i > 0),#end ${column.columnName}=#{entity.${column.javaFieldName},jdbcType=${column.mybatisJdbcType}}\n    #set($i=$i+1)       \n     #end          \n        #end    \n    WHERE ${context.pkName} = #{entity.${context.javaPkName},jdbcType=${context.mybatisPkType}}\n    </update>\n\n    <update id=\"updateByPrimaryKeySelective\" >\n        UPDATE ${table.tableName}\n        <set>\n            #foreach($column in $columns) \n                #if(!${column.isPk} and ${column.columnName} != \"create_time\" and ${column.columnName} != \"update_time\") \n                <if test=\"entity.${column.javaFieldName} !=null\">\n                    ${column.columnName}=#{entity.${column.javaFieldName},jdbcType=${column.mybatisJdbcType}},\n                </if>\n                #end\n            #end\n        </set>\n        where ${context.pkName} = #{entity.${context.javaPkName},jdbcType=${context.mybatisPkType}}\n    </update>\n\n    <select id=\"getByPrimaryKey\" resultMap=\"queryResultMap\">\n        SELECT <include refid=\"Base_Column_List\" />\n        FROM ${table.tableName} t\n        WHERE ${context.pkName} = #{id,jdbcType=${context.mybatisPkType}}\n    </select>\n    \n    <select id=\"get\" resultMap=\"queryResultMap\">\n        SELECT <include refid=\"Base_Column_List\" />\n        FROM ${table.tableName} t\n        WHERE ${context.pkName} = #{entity.${context.javaPkName},jdbcType=${context.mybatisPkType}}\n    </select>\n    \n    <delete id=\"delByPrimaryKey\" >\n        DELETE FROM ${table.tableName}\n        WHERE ${context.pkName} = #{id ,jdbcType=${context.mybatisPkType}}\n    </delete>\n\n    <delete id=\"del\">\n        DELETE FROM ${table.tableName}\n        WHERE ${context.pkName} = #{entity.${context.javaPkName},jdbcType=${context.mybatisPkType}}\n    </delete>\n\n	<insert id=\"saveBatch\">\n    	INSERT INTO ${table.tableName}\n         (\n #set ($i=0) \n        #foreach($column in $columns) \n            #if(!${column.isIdentityPk} and ${column.columnName} != \"create_time\" and ${column.columnName} != \"update_time\" and ${column.columnName} != \"is_delete\" and ${column.columnName} != \"version\")               \n        #if($i > 0),#end ${column.columnName}\n#set($i=$i +1)\n            #end          \n        #end\n          )\n    VALUES \n    <foreach collection=\"entities\" index=\"index\" item=\"entity\" separator=\",\">\n    	(\n#set ($i=0) \n        #foreach($column in $columns) \n            #if(!${column.isIdentityPk} and ${column.columnName} != \"create_time\" and ${column.columnName} != \"update_time\" and ${column.columnName} != \"is_delete\" and ${column.columnName} != \"version\")               \n        #if($i > 0),#end #{entity.${column.javaFieldName},jdbcType=${column.mybatisJdbcType}}\n#set($i=$i +1)\n            #end          \n        #end\n \n        )\n        </foreach>\n	</insert>\n	\n</mapper>', 'admin');
INSERT INTO `template_config` VALUES (49, 'v2_07_domain', 'domain', NULL, '${context.javaBeanName}.java', 'package ${context.packageName}.domain;\n\nimport infra.framework.common.dto.BaseDomain;\nimport lombok.*;\n\n#foreach($column in $columns)\n#if(${column.javaTypeBox} == \"Date\")\nimport java.util.Date;\n#break\n#end\n#end\n#foreach($column in $columns)\n#if(${column.javaTypeBox} == \"BigDecimal\")\nimport java.math.BigDecimal;\n#break\n#end\n#end\n\n@AllArgsConstructor\n@NoArgsConstructor\n@ToString(callSuper = true)\n@EqualsAndHashCode(callSuper = false)\n@Data\npublic class ${context.javaBeanName} extends BaseDomain {\n\n#foreach($column in $columns)\n	#if(${column.javaFieldName} != \"merchantId2\")\n	/** ${column.comment} */\n	private ${column.javaTypeBox} ${column.javaFieldName};\n    #end\n#end\n\n}', 'admin');
INSERT INTO `template_config` VALUES (51, 'v2_03_dto', 'dto', NULL, '${context.javaBeanName}Dto.java', 'package ${context.packageName}.dto;\n\nimport lombok.*;\n\nimport java.io.Serializable;\n\n#foreach($column in $columns)\n#if(${column.javaTypeBox} == \"Date\")\nimport java.util.Date;\n#break\n#end\n#end\n#foreach($column in $columns)\n#if(${column.javaTypeBox} == \"BigDecimal\")\nimport java.math.BigDecimal;\n#break\n#end\n#end\n\n\n/**\n *${table.comment}?????Dto\n*/\n@AllArgsConstructor\n@NoArgsConstructor\n@ToString(callSuper = true)\n@EqualsAndHashCode(callSuper = false)\n@Data\npublic class ${context.javaBeanName}Dto implements Serializable {\n\n#foreach($column in $columns)\n	#if(${column.javaFieldName} != \"merchantId\")\n	/** ${column.comment} */\n	private ${column.javaTypeBox} ${column.javaFieldName};\n    #end\n#end\n\n}', 'admin');
INSERT INTO `template_config` VALUES (54, 'v2_02_managerImpl', 'manager/impl', NULL, '${context.javaBeanName}ManagerImpl.java', 'package ${context.packageName}.manager.impl;\n\nimport ${context.packageName}.domain.${context.javaBeanName};\nimport ${context.packageName}.domain.${context.javaBeanName}Query;\nimport ${context.packageName}.service.${context.javaBeanName}Service;\nimport ${context.packageName}.manager.${context.javaBeanName}Manager;\nimport infra.framework.common.manager.impl.AbstractBaseManager;\nimport org.springframework.stereotype.Service;\n\n@Service\npublic class ${context.javaBeanName}ManagerImpl extends AbstractBaseManager<${context.javaBeanName}Service, ${context.javaBeanName}, ${context.javaBeanName}Query> implements ${context.javaBeanName}Manager {\n}', 'admin');
INSERT INTO `template_config` VALUES (55, 'v2_05_serviceImpl', 'service/impl', NULL, '${context.javaBeanName}ServiceImpl.java', 'package ${context.packageName}.service.impl;\n\nimport ${context.packageName}.dao.${context.javaBeanName}Dao;\nimport ${context.packageName}.domain.${context.javaBeanName};\nimport ${context.packageName}.domain.${context.javaBeanName}Query;\nimport ${context.packageName}.service.${context.javaBeanName}Service;\nimport infra.framework.common.service.impl.AbstractBaseService;\nimport org.springframework.stereotype.Service;\n\n@Service\npublic class ${context.javaBeanName}ServiceImpl extends AbstractBaseService<${context.javaBeanName}, ${context.javaBeanName}Query, ${context.javaBeanName}Dao> implements ${context.javaBeanName}Service {\n\n}', 'admin');
INSERT INTO `template_config` VALUES (58, 'v2_08_domain_query', 'domain', NULL, '${context.javaBeanName}Query.java', 'package ${context.packageName}.domain;\n\nimport infra.framework.common.dto.BaseQuery;\nimport lombok.*;\n\n#foreach($column in $columns)\n#if(${column.javaTypeBox} == \"Date\")\nimport java.util.Date;\n#break\n#end\n#end\n#foreach($column in $columns)\n#if(${column.javaTypeBox} == \"BigDecimal\")\nimport java.math.BigDecimal;\n#break\n#end\n#end\n\n@AllArgsConstructor\n@NoArgsConstructor\n@ToString(callSuper = true)\n@EqualsAndHashCode(callSuper = false)\n@Data\npublic class ${context.javaBeanName}Query extends BaseQuery {\n\n#foreach($column in $columns)\n	#if(${column.javaFieldName} != \"merchantId\")\n	/** ${column.comment} */\n	private ${column.javaTypeBox} ${column.javaFieldName};\n    #end\n#end\n\n}', 'admin');
INSERT INTO `template_config` VALUES (59, 'v2_11_controller', 'controller', NULL, '${context.javaBeanName}Controller.java', 'package ${context.packageName}.controller;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.RestController;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport ${context.packageName}.manager.${context.javaBeanName}Manager;\nimport ${context.packageName}.domain.${context.javaBeanName};\nimport ${context.packageName}.domain.${context.javaBeanName}Query;\nimport infra.common.base.ResponseResult;\n\nimport java.util.List;\n\n@RestController\n@RequestMapping(\"/${context.javaBeanName}\")\npublic class ${context.javaBeanName}Controller {\n\n	@Autowired\n    private ${context.javaBeanName}Manager manager;\n\n	@RequestMapping(value = \"test\", method = RequestMethod.POST)\n    public Object test(${context.javaBeanName}Query req){\n    \n		${context.javaBeanName}Query query = new ${context.javaBeanName}Query();\n		List<${context.javaBeanName}> list = manager.findByCondition(query);\n\n		return ResponseResult.success(\"success\", list);\n    }\n    \n}', 'admin');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
